Page({
  data: {
    taskinfo: { taskExplain: "财务部C2265于2018 - 11 - 25 16: 56: 48发生低墨量K", cName: '王培栋', beginDate: '2018-12-18', grade: 1, address:"华创大厦" ,phone:"17681875716", status:0},
    errorinfo:[
      { errorName: "071-450 托盘1接近空", errorCode: '071-450 Tray 1 is Near empty. Add paper to Tray 1. Printing can continue.', grade: 1, status:"一级" },
      { errorName: "075-451 托盘5已空", errorCode: '075-451 Tray 5 is empty. Add paper to Tray 5. Printing can continue.', grade: 1, status:"一级" },
      { errorName: "低墨量M", errorCode: 'The Magenta toner is out.', grade: 1, status:"一级" }
    ]
  },
  onLoad: function (options) {
    if (options.taskname){
      this.setData({
        infoId: options.taskname
      })
    }else{
      this.setData({
        name: options.name,
        turnId: options.turnId
      })
    } 
    console.log(this.data.name)  
  },
  // 接受转单
  acceptTurn: function (e) {
    wx.showModal({
      title: '提示',
      content: "确定接受 " + this.data.name + " 的转单任务 " + this.data.taskinfo.taskExplain + " 么？",
      success(res) {
        if (res.confirm) {
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  // 不接受转单
  refuseTurn: function (e) {
    wx.showModal({
      title: '提示',
      content: "确定拒绝 " + this.data.name + " 的转单任务 " + this.data.taskinfo.taskExplain  + " 么？",
      success(res) {
        if (res.confirm) {
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  // 跳转转单页面
  goTurn: function (e) {
    wx.navigateTo({
      url: '/pages/turntask/turntask?taskname=' + e.currentTarget.id,
    })
  },
  goBack: function (){
    wx.navigateBack({ changed: true });
  },
  // 拨打电话
  call:function(e){
    console.log(e.currentTarget.id);
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.id 
    })
  }
})